define([
    "UtilDir/util",
    "UtilDir/tool",
    "UtilDir/combotree",
    "UtilDir/dialog",
    "UtilDir/searchBlock",
    "HomeDir/js/router",
    "HomeDir/js/tabs",
    "EasyUI", "EasyUI-lang"
], function (Util, Tool, Combotree, Dialog, SearchBlock, Router, Tabs) {
    var sysPath = getServer() + "/static/app/fwsjcj";
    var auditFormHtml = sysPath + "/newproject/views/censusForm.html";
    var getController = function () {
        return getServer() + "/fw/reinforce";
    };

    /**
     * 页面初始化
     */
    var init = function () {
        initSearchBlock();
        queryBtnBind();
        createAuditGrid();
//      Util.preventclick("taskName");
    };

    var initSearchBlock = function () {
        SearchBlock.init("searchBlock");
    };
    var queryBtnBind = function () {
        $("#btnSearch").click(function () {
            createAuditGrid();
        });
        $("#btnReset").click(function () {
            $("#name").val("");
            $("#createUser").val("");
            $("#status").val("");
        });
    };

    // 分页列表
    var createAuditGrid = function () {
        var opts1;
        $("#auditGrid").datagrid({
            url: getController() + "/page/1",
            method: "GET",
            fitColumns: true,
            autoRowHeight: false,
            nowrap: false,
            columns: [[
                {field: "ck", checkbox: true},
                {
                    field: 'myNo',
                    title: '序号',
                    align: 'center',
                    width: '4%',
                    formatter: function (value, row, index) {
                        if (!opts1) {
                            opts1 = $('#auditGrid').datagrid('options');
                        }
                        return opts1.pageSize * (opts1.pageNumber - 1) + index + 1;
                    }
                },

                {field: 'number', title: '工程编号', width: '15%', align: 'center'},
                {field: 'name', title: '工程名称', width: '20%', align: 'center'},
                {
                    field: 'province',
                    title: '所属省',
                    width: '10%',
                    align: 'center'
                },
                {
                    field: 'city',
                    title: '所属市',
                    width: '10%',
                    align: 'center'
                },
                {
                    field: 'area',
                    title: '所属区县',
                    width: '10%',
                    align: 'center'
                },
                {
                    field: 'status', title: '数据状态', width: '10%', align: 'center',
                    formatter: function (value) {
                        if (value == 0) {
                            return '未提交';
                        } else if (value == 1) {
                            return '未审核';
                        } else if (value == 2) {
                            return '审核未通过';
                        } else if (value == 3) {
                            return '审核通过';
                        }
                    }
                },
                {field: 'createUser', title: '数据采集人', width: '10%', align: 'center'},
                {
                    field: 'operation', title: '操作', width: '10%', align: 'center',
                    formatter: function (value, rowData, rowIndex) {
                        if (rowData.status == 1) {
                            return '<a onclick="_check(\'' + rowData.id + "','" + rowData.status + '\')">审核</a >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="_view(\'' + rowData.id + "','" + rowData.status + '\')">查看表单</a >';
                        } else {
                            return '<a onclick="_view(\'' + rowData.id + "','" + rowData.status + '\')">查看表单</a >';
                        }
                    }
                }
            ]],
            toolbar: [{
                iconCls: 'fa fa-plus-circle',
                text: "批量审核",
                handler: function () {
                    batchCheck();
                }
            }, {
                iconCls: 'fa fa-trash-o',
                text: "删除",
                handler: function () {
                    deleteProject()
                }
            }, {
                iconCls: 'fa fa-download',
                text: "导出",
                handler: function () {
                    exportProject()
                }
            }/*, {
                iconCls: 'fa fa-download',
                text: "导出图片",
                handler: function () {
                    // 导出图片接口
                    exportPicture()
                }
            }*/],
            queryParams: {
                /*region: $("#region").val(),*/
                name: $("#name").val(),
                createUser: $("#createUser").val(),
                status: $("#status").val()
            },
            onLoadSuccess: function (data) {
                console.log(data)
            },
            pagination: true,
            pageSize: 10
        });
    };

        // 表单校验
    var formValidator = function () {
        $("#auditForm").validate({
            rules: {
                reason: {
                    required: true
                }
            },
            messages: {
                reason: {
                    required: "审核不通过原因不允许为空!"
                }
            }
        });
        $("#userForm").validate({
            rules: {
                province: {
                    required: true
                },
                city: {
                    required: true
                },
                area: {
                    required: true
                },
                address: {
                    required: true
                },
                name: {
                    required: true
                },
                category: {
                    required: true
                },
                type: {
                    required: true
                },
                typeSecond: {
                    required: true
                },
                typeSupplement: {
                    required: true
                },
                shelterType: {
                    required: true
                },
                shelterArea: {
                    required: true
                },
                shelterGalleryful: {
                    required: true
                },
                isShelterHaveLivingFacilities: {
                    required: true
                },
                shelterOriginalPurpose: {
                    required: true
                },
                shelterOriginalPurposeSupplement: {
                    required: true
                },
                fortificationIntensity: {
                    required: true
                },

                reinforceTime: {
                    required: true
                },
            },
            messages: {
                province: {
                    required: "请选择所属省份"
                },
                city: {
                    required: "请选择所属地级市"
                },
                area: {
                    required: "请选择所属区县"
                },
                address: {
                    required: "请填写工程地址"
                },
                name: {
                    required: "请填写工程名称"
                },
                category: {
                    required: "请选择工程类别"
                },
                type: {
                    required: "请选择工程类型"
                },
                typeSecond: {
                    required: "请选择工程类型"
                },
                typeSupplement: {
                    required: "请填写补充说明"
                },
                shelterType: {
                    required: "请填写室内或室外"
                },
                shelterArea: {
                    required: "请填写场所面积（km2）"
                },
                shelterGalleryful: {
                    required: "请填写可容纳人数（人）"
                },
                isShelterHaveLivingFacilities: {
                    required: "请选择是否配备生活设施"
                },
                shelterOriginalPurpose: {
                    required: "请选择原厂址用途"
                },
                shelterOriginalPurposeSupplement: {
                    required: "请填写补充说明"
                },
                fortificationIntensity: {
                    required: "请选择抗震设防情况"
                },

                reinforceTime: {
                    required: "请选择工程完成时间"
                },
            }
        });
    };

    // 批量审核
    var batchCheck = function () {
        debugger;
        var rows = $("#auditGrid").datagrid("getSelections");
        if (rows == null || rows.length == 0) {
            Util.alert("请选择一条数据!");
            return;
        }
        var ids;
        for (var i = 0; i < rows.length; i++) {
            if (i == 0) {
                ids = rows[i].id;
            } else {
                ids = ids + "," + rows[i].id;
            }
        }
        // 判断所选中的数据中的状态
        for (var j = 0; j < rows.length; j++) {
            if (rows[j].status != 1) {
                Util.alert('所选数据中有不处于未审核状态的！');
                return;
            }
        }

        var slidebar = Util.slidebar({
            url: auditFormHtml,
            width: "580px",
            cache: false,
            close: true,
            afterLoad: function () {
                formValidator();
                $("#approved").on("click", function () {
                    $.ajax({
                        url: getController() + "/check",
                        data: JSON.stringify({
                            status: "3",
                            ids: ids
                        }),
                        type: "post",
                        contentType: "application/json; charset=utf-8",
                        success: function (data) {
                            debugger
                            Util.alert(data.message);
                            slidebar.close();
                            createAuditGrid();
                        }
                    });
                });
                $("#unapproved").on("click", function () {
                    var reason = $('#unapproval_reason').css('display');
                    if (reason == 'none') {
                        $('#unapproval_reason').show();
                    } else {
                        formValidator();
                        if ($("#auditForm").valid()) {
                            var reason = $('#reason').val();
                            debugger;
                            $.ajax({
                                url: getController() + "/check",
                                contentType: "application/json",
                                data: JSON.stringify({
                                    ids: ids,
                                    status: '2',
                                    reason: reason
                                }),
                                type: "post",
                                success: function (data) {
                                    Util.alert(data.message);
                                    slidebar.close();
                                    createAuditGrid();
                                }
                            });
                        }
                    }
                });
            }
        });
    };

    // 导出
    var exportProject = function () {
        var name = $("#name").val();
        var createUser = $("#createUser").val();
        var status = $("#status").val();
        debugger;
        $.ajax({
            url: getController() + "/isEmpty",
            data: {
                // 项目类型：0加固工程，1新建工程
                projectType: "1",
                name: name,
                createUser: createUser,
                status: status
            },
            type: "get",
            success: function (data) {
                console.log(data);
                if (data.message == '否') {
                    window.location.href = getController() + "/export?projectType=1&name=" + name + "&createUser?" + createUser + "&status?" + status;
                } else if (data.message == '是') {
                    Util.alert('该类型数据数据为空，无法导出！');
                } else {
                    // 未选择类型，请选择一种类型！
                    Util.alert(data.message);
                }
            }
        });
    }

    // 导出多个图片为zip格式
    var exportPicture = function () {
        var buttons = [];
        buttons.push({
            name: '确定',
            callback: function () {
                //点击确定
                var formType = $("#formType").val();
                debugger;
                $.ajax({
                    url: getController() + "/isEmpty",
                    data: {
                        type: formType
                    },
                    type: "get",
                    success: function (data) {
                        console.log(data);
                        if (data.message == '否') {
                            window.location.href = getController() + "/downLoadZipFile?type=" + formType;
                        } else if (data.message == '是') {
                            Util.alert('该类型数据数据为空，无法导出！');
                        } else {
                            // 未选择类型，请选择一种类型！
                            Util.alert(data.message);
                        }
                    }
                });
                dialog.hide();
            }
        });
        var dialog = Dialog({
            id: "viewTeamDialog",
            cache: false,
            title: '选择表单类型', //dialog标题
            width: "400px",
            height: "250px",
            body: '<div id="TeamGrid">' +
                '<div class="col-md-12 form-horizontal">' +
                '<div class="form-group">' +
                '<label for="formType" class="col-md-4 control-label"> </span>表单类型:</label>' +
                '<div class="col-md-8">' +
                '<select class="form-control" id="formType" name="formType" >' +
                '<option value="" disabled selected style="display:none;">请选择</option>' +
                '<option value="0">城镇住宅</option>' +
                '<option value="1">城镇非住宅</option>' +
                '<option value="2">农村住房</option>' +
                '<option value="3">农村公共建筑</option>' +
                '</select>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>',
            buttons: buttons,
            afterOpen: function () {

            }
        });
        dialog.show();
    }

    // 删除
    var deleteProject = function () {
        var rows = $("#auditGrid").datagrid("getSelections");
        if (rows == null || rows.length == 0) {
            Util.alert("请选择一行数据!");
            return;
        } else if (rows[0].status != '1') {
            Util.alert("数据状态为未审核的才能删除!");
            return;
        } else if (rows.length >= 1) {
            for (let i = 0; i < rows.length; i++) {
                if (rows[i].status != '1') {
                    Util.alert("数据状态为未审核的才能删除!");
                    return;
                }
            }
        }
        Util.confirm("是否要删除选中的表单?", function () {
            var ids = "";
            $.each(rows, function (i, row) {
                ids += row.id + ",";
            });
            ids = ids.substr(0, ids.length - 1);
            $.ajax({
                url: getController() + "/del",
                contentType: "application/json",
                data: ids,
                type: "post",
                success: function (data) {
                    Util.alert(data.message);
                    createAuditGrid();
                }
            });
        }, function () {
            return;
        });
    }

    // 查看表单
    window._view = function (formId, state) {
        debugger;
        var censusDataHtml = '';
        if (state == 1) {
            censusDataHtml = sysPath + "/newproject/views/newprojectCheckFormV.html";
        } else if (state == 2) {
            censusDataHtml = sysPath + "/newproject/views/newprojectCheckFormN.html";
        } else if (state == 3) {
            censusDataHtml = sysPath + "/newproject/views/newprojectCheckFormY.html";
        }
        var slidebar = Util.slidebar({
            url: censusDataHtml,
            width: "900px",
            cache: false,
            close: true,
            afterLoad: function () {
                formValidator();
                getData(formId, state);
                require(["jquery", "Date", "DateCN", "css!DateCss"], function ($) {
                    $("#reinforceTime").datetimepicker({
                        language: 'cn',
                        // 输出格式化
                        format: 'yyyy-mm',
						weekStart: 1,
                        // 设置最精确的时间选择视图
                        startView: 3,
         				minView: 3,
                        forceParse: false,         
                        // 选择完毕后自动关闭
                        autoclose: true
                    });
                    //删除按钮
                    $("#complex_del").on("click", function () {
                        $("#reinforceTime").val("");
                    });
                });
                // 保存按钮（其实就是修改）
                $("#saveBtn").on("click", function () {
                    if ($("#userForm").valid()) {
                        var data = Tool.serialize("userForm");
                        $.ajax({
                            url: getController() + "/update",
                            contentType: "application/json",
                            data: JSON.stringify(data),
                            type: "post",
                            success: function (data) {
                                Util.alert(data.message);
                                slidebar.close();
                                createAuditGrid();
                            }
                        });
                    }
                });
            }
        });
    };

    // 审核
    window._check = function (formId, state) {
        var censusCheckDataHtml = '';
        if (state == 2) {
            censusCheckDataHtml = sysPath + "/newproject/views/newprojectCheckFormR.html";
        } else {
            censusCheckDataHtml = sysPath + "/newproject/views/newprojectCheckForm.html";
        }
        var slidebar = Util.slidebar({
            url: censusCheckDataHtml,
            width: "900px",
            cache: false,
            close: true,
            afterLoad: function () {
                formValidator();
                getData(formId);
                //日期组件
                require(["jquery", "Date", "DateCN", "css!DateCss"], function ($) {
                    $("#reinforceTime").datetimepicker({
                        language: 'cn',
                        // 输出格式化
                        format: 'yyyy-mm',
						weekStart: 1,
                        // 设置最精确的时间选择视图
                        startView: 3,
         				minView: 3,
                        forceParse: false,         
                        // 选择完毕后自动关闭
                        autoclose: true
                    });
                    //删除按钮
                    $("#complex_del").on("click", function () {
                        $("#reinforceTime").val("");
                    });
                });
                // 审核通过按钮
                $("#approved").on("click", function () {
                	if ($("#userForm").valid()) {
	                	var data = Tool.serialize("userForm");
	                	data.status="3";                	
	                    $.ajax({
	                        url: getController() + "/checkone",
	                        data: JSON.stringify(data),
	                        type: "post",
	                        contentType: "application/json; charset=utf-8",
	                        success: function (data) {
	                            debugger
	                            Util.alert(data.message);
	                            slidebar.close();
	                            createAuditGrid();
	                        }
	                    });
	                } 
                });
                // 审核未通过按钮
                $("#unapproved").on("click", function () {
                	if ($("#userForm").valid()) {
	                    debugger;
	                    var reason = $('#unapproval_reason').css('display');
	                    if (reason == 'none') {
	                        $('#unapproval_reason').show();
	                    } else {
	                        formValidator();
	                        if ($('#auditForm').valid()) {
	                            var data = Tool.serialize("userForm");
	                            data.reason = $('#reason').val();
	                            data.status = "2";
	                            $.ajax({
	                                url: getController() + "/checkone",
	                                data: JSON.stringify(data),
	                                type: "post",
	                                contentType: "application/json; charset=utf-8",
	                                success: function (data) {
	                                    debugger
	                                    $('#unapproval_reason').hide();
	                                    Util.alert(data.message);
	                                    slidebar.close();
	                                    createAuditGrid();
	                                }
	                            });
	                        }
	                    }
	                }
                });
//              // 保存按钮（其实就是修改）
//              $("#saveBtn").on("click", function () {
//                  if ($("#userForm").valid()) {
//                      var data = Tool.serialize("userForm");
//                      $.ajax({
//                          url: getController() + "/update",
//                          contentType: "application/json",
//                          data: JSON.stringify(data),
//                          type: "post",
//                          success: function (data) {
//                              Util.alert(data.message);
//                              slidebar.close();
//                              createAuditGrid();
//                          }
//                      });
//                  }
//              });
            }
        });
    };

    // 查询一条数据
    var getData = function (id, status) {
        debugger;
        $.ajax({
            url: getController() + "/getone/" + id,
            type: "get",
            success: function (data) {
                //console.log(data)
                editProvince(data.province, data.city, data.area);
                editType(data.category, data.typeSecond);
                Tool.deserialize("userForm", data);
                if (status == 2) {
                    $('#unapproval_reason').show();
                    $("#reason").val(data.reason);
                }
                if (data.pictureCompleteConstruction) {
                    var imageURL = data.pictureCompleteConstruction.split(",");
                    console.log(imageURL);
                    var html = "";
                    for (var i = 0; i < imageURL.length; i++) {
                        html += '<div class="col-md-12 has-feedback" style="padding-top: 7px;display: flex;justify-content: center;">' +
                            '<img src=' + imageURL[i] + ' alt="暂无图片" id="+image[i]+" name="+image[i]+" style="width: 400px;height: 533px;border: 1px solid #ddd;"/>' +
                            '</div>'
                    }
                    $("#pictureCompleteConstruction").append(html);
                } else {
                    var html = "";
                    html += '<div class="col-md-12 has-feedback" style="padding-top: 7px;display: flex;justify-content: center;">' +
                        '<img src="" alt="暂无图片" id="image" name="image" style="width: 400px;height: 533px;border: 1px solid #ddd;"/>' +
                        '</div>'
                    $("#pictureCompleteConstruction").append(html);
                }
                if (data.type == '其它') {
                    $('#typeSupplement').css('display', 'block');
                }

 
            }
        });
    }
    // 编辑省市区
    var editProvince = function (Province, City, Area) {
        debugger;
        var html = "";
        $("#belongtoCity").append(html);
        $("#belongtoArea").append(html);
        $.ajax({
            url: "/app/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    if (item.divisionName == Province) {
                        debugger;
                        var divisionId = item.divisionId;
                        var htmlCity = '';
                        if (Province == "北京市" || Province == "天津市" || Province == "上海市" || Province == "重庆市") {
                            $("#belongtoCity").append("<option value='" + Province + "' exid='" + divisionId + "'>" + Province + "</option>");
                            $('#belongtoCity').val(City);
                            var htmlArea = '';
                            $.ajax({
                                url: "/app/divisions/" + divisionId + "/subdivisions",
                                contentType: "application/json",
                                type: "get",
                                success: function (data) {
                                    $.each(data, function (idx, item) {
                                        htmlArea += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                    });
                                    $("#belongtoArea").append(htmlArea);
                                    $('#belongtoArea').val(Area);
                                }
                            });

                        } else {
                            $.ajax({
                                url: "/app/divisions/" + divisionId + "/subdivisions",
                                contentType: "application/json",
                                type: "get",
                                success: function (data) {
                                    debugger;
                                    $.each(data, function (idx, item) {
                                        if (item.divisionName == City) {
                                            var divisionId = item.divisionId;
                                            var htmlArea = '';
                                            $.ajax({
                                                url: "/app/divisions/" + divisionId + "/subdivisions",
                                                contentType: "application/json",
                                                type: "get",
                                                success: function (data) {
                                                    $.each(data, function (idx, item) {
                                                        htmlArea += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                                    });
                                                    $("#belongtoArea").append(htmlArea);
                                                    $('#belongtoArea').val(Area);
                                                }
                                            });
                                        }
                                        htmlCity += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                    });
                                    $("#belongtoCity").append(htmlCity);
                                    $('#belongtoCity').val(City);
                                }
                            });
                        }
                    }
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#belongtoProvince").append(html);
                $('#belongtoProvince').val(Province);
            }
        });
        $("#belongtoProvince").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#belongtoCity option").remove();
            $("#belongtoCity").append(html);
            $("#belongtoArea option").remove();
            $("#belongtoArea").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                $("#belongtoCity").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                return;
            }
            $.ajax({
                url: "/app/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#belongtoCity").append(html);
                }
            });
        });
        $("#belongtoCity").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#belongtoArea option").remove();
            $("#belongtoArea").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: "/app/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#belongtoArea").append(html);
                }
            });
        });
    }
	// 编辑类型
    var editType = function (category, typeSecond) {
        
		var htmlSecond = '';
        if(category == "城镇住宅"||category == "大中小学校"||category =="医院"||category =="农村民居"){
			htmlSecond = '<option value="砖混结构">砖混结构</option>'+
					'<option value="钢混结构">钢混结构</option>'+
					'<option value="砖木结构">砖木结构</option>'+
					'<option value="钢结构">钢结构</option>'+
					'<option value="木结构">木结构</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "重要交通生命线"){
			htmlSecond = '<option value="桥梁">桥梁</option>'+
					'<option value="隧道">隧道</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "电力网络"){
			htmlSecond = '<option value="电力网络设施">电力网络设施</option>'+
					'<option value="发电站">发电站</option>'+
					'<option value="变电站">变电站</option>'+
					'<option value="办公楼等配套设施">办公楼等配套设施</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "电信网络"){
			htmlSecond = '<option value="电信网络设施">电信网络设施</option>'+
					'<option value="生产用房">生产用房</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "危险化学品厂库"){
			htmlSecond = '<option value="设备装置">设备装置</option>'+
					'<option value="生产存储用房">生产存储用房</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "水库大坝"){
			htmlSecond = '<option value="土石坝">土石坝</option>'+
					'<option value="砌石坝">砌石坝</option>'+
					'<option value="混凝土坝">混凝土坝</option>'+
					'<option value="橡胶坝">橡胶坝</option>'+
					'<option value="其它">其它</option>'
		}else if(category == "应急避难场所建设"){
			htmlSecond = '<option value="室内">室内</option>'+
					'<option value="室外">室外</option>'
			$('#asylumtype').css('display', 'block');
			
		}
        $("#type").append(htmlSecond);
        $("#category").change(function () {
        	$('#asylumtype').css('display', 'none');
        	$('#typeSupplement').css('display', 'none');
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#type option").remove();
            $("#type").append(html);
            debugger;
			if($(this).val() == "城镇住宅"||$(this).val() =="大中小学校"||$(this).val() =="医院"||$(this).val() =="农村民居"){
				html = 	'<option value="砖混结构">砖混结构</option>'+
						'<option value="钢混结构">钢混结构</option>'+
						'<option value="砖木结构">砖木结构</option>'+
						'<option value="钢结构">钢结构</option>'+
						'<option value="木结构">木结构</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "重要交通生命线"){
				html = 	'<option value="桥梁">桥梁</option>'+
						'<option value="隧道">隧道</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "电力网络"){
				html = 	'<option value="电力网络设施">电力网络设施</option>'+
						'<option value="发电站">发电站</option>'+
						'<option value="变电站">变电站</option>'+
						'<option value="办公楼等配套设施">办公楼等配套设施</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "电信网络"){
				html = '<option value="电信网络设施">电信网络设施</option>'+
						'<option value="生产用房">生产用房</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "危险化学品厂库"){
				html = '<option value="设备装置">设备装置</option>'+
						'<option value="生产存储用房">生产存储用房</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "水库大坝"){
				html = '<option value="土石坝">土石坝</option>'+
						'<option value="砌石坝">砌石坝</option>'+
						'<option value="混凝土坝">混凝土坝</option>'+
						'<option value="橡胶坝">橡胶坝</option>'+
						'<option value="其它">其它</option>'
			}else if($(this).val() == "应急避难场所建设"){
				html = '<option value="室内">室内</option>'+
					'<option value="室外">室外</option>'
				$('#asylumtype').css('display', 'block');
			}
			$("#type").append(html);
           
        });
        $("#type").change(function () {
        	$('#typeSupplement').css('display', 'none');
        	$('#typeSupplement').val('');
            if ($(this).val() == "其它"){
            	$('#typeSupplement').css('display', 'block');
            }
            
        });
 
    }
    return {
        init: init
    };
});
